#version 450

layout(location=0) in vec3 a_Pos;
layout(location=1) in vec3 a_Normal;
layout(location=2) in vec3 a_Color;
layout(location=3) in vec2 a_Texcoord;

layout (binding = 0) uniform UBO
{
    mat4 projViewMat;
    mat4 viewMat;
    vec4 lightPos;
    vec4 viewPos;
} ubo;

layout(location=0) out vec3 v_Normal;
layout(location=1) out vec3 v_Color;
layout(location=2) out vec2 v_Texcoord;
layout(location=3) out vec3 v_LightVec;
layout(location=4) out vec3 v_ViewVec;

void main() {
    vec4 worldPos = vec4(a_Pos, 1.0);
    gl_Position = ubo.projViewMat * ubo.viewMat * worldPos;
    v_Normal = a_Normal;
    v_Color = a_Color;
    v_Texcoord = a_Texcoord;
    v_LightVec = (ubo.lightPos - worldPos).xyz;
    v_ViewVec = (ubo.viewPos - worldPos).xyz;
}